<template>
  <div class="profile-container" style="background: white; min-height: 100vh; padding: 20px;">

    <!-- 简化的页面标题 -->
    <div class="page-header" style="background: #f5f5f5; padding: 20px; margin-bottom: 20px; border-radius: 8px;">
      <div class="header-content">
        <div class="title-section">
          <h2 class="page-title" style="margin: 0; color: #333;">
            个人信息设置
          </h2>
          <p class="page-description" style="margin: 5px 0 0 0; color: #666;">管理您的个人信息和账户设置</p>
        </div>
        <div class="header-actions">
          <button @click="fetchProfile" :disabled="refreshLoading"
                  style="padding: 10px 20px; background: #409EFF; color: white; border: none; border-radius: 4px; cursor: pointer;">
            {{ refreshLoading ? '刷新中...' : '刷新信息' }}
          </button>
        </div>
      </div>
    </div>

    <div class="profile-content">
      <!-- 左侧头像区域 -->
      <div class="avatar-section">
        <div class="avatar-card">
          <div class="avatar-wrapper">
            <Avatar
              :src="profileForm.avatar"
              :size="140"
              alt="用户头像"
              class="user-avatar"
            />
            <div class="avatar-info">
              <el-icon><InfoFilled /></el-icon>
              <span>默认头像</span>
            </div>
          </div>
          <div class="user-info">
            <h3 class="username">{{ profileForm.username || '未设置' }}</h3>
            <p class="user-role">
              <el-tag type="success" size="small">
                <el-icon><User /></el-icon>
                系统管理员
              </el-tag>
            </p>
            <div class="user-stats">
              <div class="stat-item">
                <span class="stat-label">注册时间</span>
                <span class="stat-value">{{ formatDate(profileForm.createdAt) }}</span>
              </div>
              <div class="stat-item">
                <span class="stat-label">最后更新</span>
                <span class="stat-value">{{ formatDate(profileForm.updatedAt) }}</span>
              </div>
            </div>
          </div>


        </div>
      </div>

      <!-- 右侧信息区域 -->
      <div class="info-section">
        <el-tabs v-model="activeTab" class="profile-tabs">
          <!-- 基本信息 -->
          <el-tab-pane name="basic">
            <template #label>
              <span class="tab-label">
                <el-icon><User /></el-icon>
                基本信息
              </span>
            </template>

            <div class="form-section">
              <div class="section-header">
                <h3 class="section-title">个人资料</h3>
                <p class="section-desc">管理您的基本个人信息</p>
              </div>

              <el-form
                ref="profileFormRef"
                :model="profileForm"
                :rules="profileRules"
                label-width="120px"
                class="profile-form"
                label-position="left"
              >
                <el-row :gutter="24">
                  <el-col :span="12">
                    <el-form-item label="用户名" prop="username">
                      <el-input
                        v-model="profileForm.username"
                        placeholder="请输入用户名"
                        :prefix-icon="User"
                        size="large"
                        clearable
                      />
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item label="显示名称" prop="name">
                      <el-input
                        v-model="profileForm.name"
                        placeholder="请输入显示名称"
                        :prefix-icon="User"
                        size="large"
                        clearable
                      />
                      <div class="field-tip">
                        <el-icon><InfoFilled /></el-icon>
                        用于在系统中显示的名称
                      </div>
                    </el-form-item>
                  </el-col>
                </el-row>

                <el-row :gutter="24">
                  <el-col :span="12">
                    <el-form-item label="邮箱地址" prop="email">
                      <el-input
                        v-model="profileForm.email"
                        placeholder="请输入邮箱地址"
                        :prefix-icon="Message"
                        size="large"
                        clearable
                      />
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item label="账户状态">
                      <el-tag :type="profileForm.status === 1 ? 'success' : 'danger'" size="large">
                        <el-icon>
                          <CircleCheckFilled v-if="profileForm.status === 1" />
                          <CircleCloseFilled v-else />
                        </el-icon>
                        {{ profileForm.status === 1 ? '正常' : '禁用' }}
                      </el-tag>
                    </el-form-item>
                  </el-col>
                </el-row>

                <el-form-item label="个人简介" prop="bio">
                  <el-input
                    v-model="profileForm.bio"
                    type="textarea"
                    :rows="4"
                    placeholder="请输入个人简介（可选）"
                    maxlength="200"
                    show-word-limit
                    size="large"
                  />
                </el-form-item>

                <div class="form-actions">
                  <el-button
                    type="primary"
                    @click="handleUpdateProfile"
                    :loading="updateLoading"
                    size="large"
                    class="save-btn"
                  >
                    <el-icon><Check /></el-icon>
                    保存修改
                  </el-button>
                  <el-button @click="handleReset" size="large">
                    <el-icon><RefreshRight /></el-icon>
                    重置表单
                  </el-button>
                </div>
              </el-form>
            </div>
          </el-tab-pane>

          <!-- 密码修改 -->
          <el-tab-pane name="password">
            <template #label>
              <span class="tab-label">
                <el-icon><Lock /></el-icon>
                密码修改
              </span>
            </template>

            <div class="form-section">
              <div class="section-header">
                <h3 class="section-title">安全设置</h3>
                <p class="section-desc">修改您的登录密码以保护账户安全</p>
              </div>

              <div class="security-tips">
                <el-alert
                  title="密码安全提示"
                  type="info"
                  :closable="false"
                  show-icon
                >
                  <template #default>
                    <ul class="tips-list">
                      <li>密码长度至少6位字符</li>
                      <li>建议包含字母、数字和特殊字符</li>
                      <li>定期更换密码以保护账户安全</li>
                    </ul>
                  </template>
                </el-alert>
              </div>

              <el-form
                ref="passwordFormRef"
                :model="passwordForm"
                :rules="passwordRules"
                label-width="120px"
                class="password-form"
                label-position="left"
              >
                <el-form-item label="当前密码" prop="oldPassword">
                  <el-input
                    v-model="passwordForm.oldPassword"
                    type="password"
                    placeholder="请输入当前密码"
                    :prefix-icon="Lock"
                    show-password
                    size="large"
                    clearable
                  />
                </el-form-item>

                <el-form-item label="新密码" prop="newPassword">
                  <el-input
                    v-model="passwordForm.newPassword"
                    type="password"
                    placeholder="请输入新密码"
                    :prefix-icon="Lock"
                    show-password
                    size="large"
                    clearable
                  />
                  <div class="password-strength">
                    <span class="strength-label">密码强度：</span>
                    <div class="strength-bar">
                      <div
                        class="strength-fill"
                        :class="passwordStrengthClass"
                        :style="{ width: passwordStrengthWidth }"
                      ></div>
                    </div>
                    <span class="strength-text" :class="passwordStrengthClass">
                      {{ passwordStrengthText }}
                    </span>
                  </div>
                </el-form-item>

                <el-form-item label="确认新密码" prop="confirmPassword">
                  <el-input
                    v-model="passwordForm.confirmPassword"
                    type="password"
                    placeholder="请再次输入新密码"
                    :prefix-icon="Lock"
                    show-password
                    size="large"
                    clearable
                  />
                </el-form-item>

                <div class="form-actions">
                  <el-button
                    type="primary"
                    @click="handleChangePassword"
                    :loading="passwordLoading"
                    size="large"
                    class="save-btn"
                  >
                    <el-icon><Check /></el-icon>
                    修改密码
                  </el-button>
                  <el-button @click="handlePasswordReset" size="large">
                    <el-icon><RefreshRight /></el-icon>
                    重置表单
                  </el-button>
                </div>
              </el-form>
            </div>
          </el-tab-pane>

          <!-- 账户信息 -->
          <el-tab-pane name="account">
            <template #label>
              <span class="tab-label">
                <el-icon><Setting /></el-icon>
                账户信息
              </span>
            </template>

            <div class="form-section">
              <div class="section-header">
                <h3 class="section-title">账户详情</h3>
                <p class="section-desc">查看您的账户详细信息</p>
              </div>

              <div class="account-info">
                <div class="info-grid">
                  <div class="info-item">
                    <div class="info-label">
                      <el-icon><Key /></el-icon>
                      用户ID
                    </div>
                    <div class="info-value">{{ profileForm.id || '未设置' }}</div>
                  </div>

                  <div class="info-item">
                    <div class="info-label">
                      <el-icon><User /></el-icon>
                      用户名
                    </div>
                    <div class="info-value">{{ profileForm.username || '未设置' }}</div>
                  </div>

                  <div class="info-item">
                    <div class="info-label">
                      <el-icon><Message /></el-icon>
                      邮箱地址
                    </div>
                    <div class="info-value">{{ profileForm.email || '未设置' }}</div>
                  </div>

                  <div class="info-item">
                    <div class="info-label">
                      <el-icon><Calendar /></el-icon>
                      注册时间
                    </div>
                    <div class="info-value">{{ formatDate(profileForm.createdAt) }}</div>
                  </div>

                  <div class="info-item">
                    <div class="info-label">
                      <el-icon><Clock /></el-icon>
                      最后更新
                    </div>
                    <div class="info-value">{{ formatDate(profileForm.updatedAt) }}</div>
                  </div>

                  <div class="info-item">
                    <div class="info-label">
                      <el-icon><CircleCheck /></el-icon>
                      账户状态
                    </div>
                    <div class="info-value">
                      <el-tag :type="profileForm.status === 1 ? 'success' : 'danger'">
                        {{ profileForm.status === 1 ? '正常' : '禁用' }}
                      </el-tag>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </el-tab-pane>
        </el-tabs>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref, reactive, onMounted, nextTick, watch, computed } from 'vue'
import { useRoute } from 'vue-router'
import { ElMessage, ElMessageBox } from 'element-plus'
import {
  User, Camera, Message, Phone, Lock, Check, Refresh, RefreshRight,
  Loading, InfoFilled, CircleCheckFilled, CircleCloseFilled,
  Setting, Key, Calendar, Clock, CircleCheck
} from '@element-plus/icons-vue'
import Avatar from '@/components/Avatar.vue'
import {
  getProfile,
  updateProfile,
  changePassword
} from '@/api/profile'

// 路由
const route = useRoute()

// 响应式数据
const activeTab = ref('basic')
const updateLoading = ref(false)
const passwordLoading = ref(false)
const refreshLoading = ref(false)


// 表单ref
const profileFormRef = ref(null)
const passwordFormRef = ref(null)


// 个人信息表单
const profileForm = reactive({
  id: null,
  username: '',
  name: '',
  email: '',
  bio: '',
  avatar: '',
  status: 1,
  createdAt: null,
  updatedAt: null
})

// 原始数据备份
const originalProfileData = reactive({})

// 密码表单
const passwordForm = reactive({
  oldPassword: '',
  newPassword: '',
  confirmPassword: ''
})

// 表单验证规则
const profileRules = {
  username: [
    { required: true, message: '请输入用户名', trigger: 'blur' },
    { min: 3, max: 20, message: '用户名长度在 3 到 20 个字符', trigger: 'blur' },
    { pattern: /^[a-zA-Z0-9_]+$/, message: '用户名只能包含字母、数字和下划线', trigger: 'blur' }
  ],
  name: [
    { required: true, message: '请输入显示名称', trigger: 'blur' },
    { min: 2, max: 50, message: '显示名称长度在 2 到 50 个字符', trigger: 'blur' }
  ],
  email: [
    { type: 'email', message: '请输入正确的邮箱地址', trigger: 'blur' }
  ],
  bio: [
    { max: 200, message: '个人简介不能超过200个字符', trigger: 'blur' }
  ]
}

const passwordRules = {
  oldPassword: [
    { required: true, message: '请输入当前密码', trigger: 'blur' }
  ],
  newPassword: [
    { required: true, message: '请输入新密码', trigger: 'blur' },
    { min: 6, message: '密码长度不能少于6位', trigger: 'blur' },
    { max: 50, message: '密码长度不能超过50位', trigger: 'blur' }
  ],
  confirmPassword: [
    { required: true, message: '请再次输入新密码', trigger: 'blur' },
    {
      validator: (rule, value, callback) => {
        if (value !== passwordForm.newPassword) {
          callback(new Error('两次输入的密码不一致'))
        } else {
          callback()
        }
      },
      trigger: 'blur'
    }
  ]
}

// 密码强度检测
const passwordStrength = computed(() => {
  const password = passwordForm.newPassword
  if (!password) return 0

  let strength = 0
  // 长度检查
  if (password.length >= 6) strength += 1
  if (password.length >= 8) strength += 1
  // 包含数字
  if (/\d/.test(password)) strength += 1
  // 包含小写字母
  if (/[a-z]/.test(password)) strength += 1
  // 包含大写字母
  if (/[A-Z]/.test(password)) strength += 1
  // 包含特殊字符
  if (/[!@#$%^&*(),.?":{}|<>]/.test(password)) strength += 1

  return strength
})

const passwordStrengthClass = computed(() => {
  const strength = passwordStrength.value
  if (strength <= 2) return 'weak'
  if (strength <= 4) return 'medium'
  return 'strong'
})

const passwordStrengthText = computed(() => {
  const strength = passwordStrength.value
  if (strength <= 2) return '弱'
  if (strength <= 4) return '中等'
  return '强'
})

const passwordStrengthWidth = computed(() => {
  return `${(passwordStrength.value / 6) * 100}%`
})

// 格式化日期
const formatDate = (date) => {
  if (!date) return '未设置'
  return new Date(date).toLocaleString('zh-CN', {
    year: 'numeric',
    month: '2-digit',
    day: '2-digit',
    hour: '2-digit',
    minute: '2-digit'
  })
}

// 获取个人信息
const fetchProfile = async () => {
  try {
    refreshLoading.value = true


    const response = await getProfile()


    // 检查响应格式
    if (response.code === 200 && response.data) {


      // 映射后端数据到前端表单
      const backendData = response.data
      const mappedData = {
        id: backendData.id,
        username: backendData.username || '',
        name: backendData.name || '', // 显示名称
        email: backendData.email || '',
        bio: '', // 个人简介，后端暂无此字段
        avatar: '', // 头像，后端暂无此字段
        status: backendData.status || 1,
        createdAt: backendData.createdAt,
        updatedAt: backendData.updatedAt
      }



      Object.assign(profileForm, mappedData)
      Object.assign(originalProfileData, mappedData)


      ElMessage.success('个人信息获取成功')
    } else {

      ElMessage.error(response.msg || '获取个人信息失败')
    }
  } catch (error) {

    ElMessage.error('获取个人信息失败: ' + error.message)
  } finally {
    refreshLoading.value = false
  }
}

// 更新个人信息
const handleUpdateProfile = async () => {
  const formRef = profileFormRef.value
  if (!formRef) return

  try {
    await formRef.validate()
    updateLoading.value = true

    // 映射前端数据到后端格式
    const updateData = {
      username: profileForm.username,
      name: profileForm.name,
      email: profileForm.email
      // 注意：bio、avatar字段后端暂不支持
    }

    const response = await updateProfile(updateData)


    if (response.code === 200) {
      ElMessage.success('个人信息更新成功')
      Object.assign(originalProfileData, profileForm)
      // 刷新页面数据
      await fetchProfile()
    } else {
      ElMessage.error(response.msg || '更新失败')
    }
  } catch (error) {
    if (error !== false) {
      console.error('更新个人信息失败:', error)
      ElMessage.error('更新失败，请重试')
    }
  } finally {
    updateLoading.value = false
  }
}

// 重置个人信息表单
const handleReset = () => {
  Object.assign(profileForm, originalProfileData)
  nextTick(() => {
    if (profileFormRef.value) {
      profileFormRef.value.clearValidate()
    }
  })
}

// 修改密码
const handleChangePassword = async () => {
  const formRef = passwordFormRef.value
  if (!formRef) return

  try {
    await formRef.validate()
    passwordLoading.value = true

    const response = await changePassword(passwordForm)


    if (response.code === 200) {
      ElMessage.success('密码修改成功')
      handlePasswordReset()
    } else {
      ElMessage.error(response.msg || '密码修改失败')
    }
  } catch (error) {
    if (error !== false) {
      console.error('修改密码失败:', error)
      ElMessage.error('修改密码失败，请重试')
    }
  } finally {
    passwordLoading.value = false
  }
}

// 重置密码表单
const handlePasswordReset = () => {
  Object.assign(passwordForm, {
    oldPassword: '',
    newPassword: '',
    confirmPassword: ''
  })
  nextTick(() => {
    if (passwordFormRef.value) {
      passwordFormRef.value.clearValidate()
    }
  })
}



// 监听路由参数变化
watch(() => route.query.tab, (newTab) => {
  if (newTab && ['basic', 'password', 'account'].includes(newTab)) {
    activeTab.value = newTab
  }
}, { immediate: true })

// 页面加载时获取数据
onMounted(() => {
  fetchProfile()
})
</script>

<style scoped>
.profile-container {
  padding: 24px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: calc(100vh - 60px);
}

.page-header {
  margin-bottom: 32px;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  border-radius: 16px;
  padding: 24px;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 1200px;
  margin: 0 auto;
}

.title-section {
  text-align: left;
}

.page-title {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 32px;
  font-weight: 700;
  color: white;
  margin: 0 0 8px 0;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.title-icon {
  font-size: 36px;
  color: #ffd700;
}

.page-description {
  color: rgba(255, 255, 255, 0.8);
  font-size: 16px;
  margin: 0;
}

.header-actions .el-button {
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: white;
  backdrop-filter: blur(10px);
}

.header-actions .el-button:hover {
  background: rgba(255, 255, 255, 0.3);
  border-color: rgba(255, 255, 255, 0.5);
}

.profile-content {
  display: flex;
  gap: 24px;
  max-width: 1200px;
  margin: 0 auto;
}

/* 左侧头像区域 */
.avatar-section {
  flex: 0 0 320px;
}

.avatar-card {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  border-radius: 20px;
  padding: 32px 24px;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.avatar-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}

.avatar-wrapper {
  position: relative;
  display: inline-block;
  margin-bottom: 24px;
}

.user-avatar {
  border: 5px solid #fff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  transition: transform 0.3s ease;
}

.avatar-info {
  position: absolute;
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(103, 126, 234, 0.9);
  color: white;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 4px;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.avatar-info .el-icon {
  font-size: 14px;
}

.user-info {
  text-align: center;
}

.username {
  font-size: 24px;
  font-weight: 600;
  color: #2c3e50;
  margin: 0 0 12px 0;
}

.user-role {
  margin: 0 0 20px 0;
}

.user-role .el-tag {
  font-size: 14px;
  padding: 8px 16px;
  border-radius: 20px;
  border: none;
  background: linear-gradient(45deg, #52c41a, #73d13d);
  color: white;
}

.user-stats {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid #e8e8e8;
}

.stat-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
}

.stat-label {
  color: #666;
  font-weight: 500;
}

.stat-value {
  color: #2c3e50;
  font-weight: 600;
}

/* 右侧信息区域 */
.info-section {
  flex: 1;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  border-radius: 20px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  overflow: hidden;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.info-section:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}

.profile-tabs {
  height: 100%;
}

.profile-tabs :deep(.el-tabs__header) {
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  margin: 0;
  padding: 0 32px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.profile-tabs :deep(.el-tabs__nav-wrap) {
  padding: 0;
}

.profile-tabs :deep(.el-tabs__item) {
  font-size: 16px;
  font-weight: 600;
  height: 64px;
  line-height: 64px;
  color: #666;
  transition: all 0.3s ease;
  border-radius: 8px 8px 0 0;
  margin-right: 8px;
}

.profile-tabs :deep(.el-tabs__item:hover) {
  color: #667eea;
  background: rgba(102, 126, 234, 0.1);
}

.profile-tabs :deep(.el-tabs__item.is-active) {
  color: #667eea;
  background: rgba(102, 126, 234, 0.1);
  font-weight: 700;
}

.profile-tabs :deep(.el-tabs__active-bar) {
  background: linear-gradient(90deg, #667eea, #764ba2);
  height: 3px;
}

.tab-label {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tab-label .el-icon {
  font-size: 18px;
}

/* 表单区域 */
.form-section {
  padding: 32px;
}

.section-header {
  margin-bottom: 32px;
  text-align: center;
  padding-bottom: 20px;
  border-bottom: 2px solid #f0f0f0;
}

.section-title {
  font-size: 24px;
  font-weight: 700;
  color: #2c3e50;
  margin: 0 0 8px 0;
  background: linear-gradient(135deg, #667eea, #764ba2);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.section-desc {
  color: #666;
  font-size: 16px;
  margin: 0;
}

.profile-form {
  max-width: 100%;
}

.profile-form :deep(.el-form-item__label) {
  font-weight: 600;
  color: #2c3e50;
}

.profile-form :deep(.el-input__wrapper) {
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  border: 1px solid #e0e0e0;
  transition: all 0.3s ease;
}

.profile-form :deep(.el-input__wrapper:hover) {
  border-color: #667eea;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}

.profile-form :deep(.el-input__wrapper.is-focus) {
  border-color: #667eea;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.profile-form :deep(.el-textarea__inner) {
  border-radius: 12px;
  border: 1px solid #e0e0e0;
  transition: all 0.3s ease;
}

.profile-form :deep(.el-textarea__inner:hover) {
  border-color: #667eea;
}

.profile-form :deep(.el-textarea__inner:focus) {
  border-color: #667eea;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.field-tip {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: #999;
  margin-top: 4px;
}

.field-tip .el-icon {
  font-size: 14px;
}

.form-actions {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid #f0f0f0;
}

.save-btn {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
  border-radius: 25px;
  padding: 12px 32px;
  font-weight: 600;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
  transition: all 0.3s ease;
}

.save-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

/* 密码表单特殊样式 */
.password-form {
  max-width: 600px;
}

.password-form :deep(.el-form-item) {
  margin-bottom: 24px;
}

.security-tips {
  margin-bottom: 24px;
}

.tips-list {
  margin: 0;
  padding-left: 20px;
  color: #666;
}

.tips-list li {
  margin-bottom: 4px;
}

.password-strength {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
  font-size: 12px;
}

.strength-label {
  color: #666;
  font-weight: 500;
}

.strength-bar {
  flex: 1;
  height: 4px;
  background: #f0f0f0;
  border-radius: 2px;
  overflow: hidden;
}

.strength-fill {
  height: 100%;
  transition: all 0.3s ease;
  border-radius: 2px;
}

.strength-fill.weak {
  background: linear-gradient(90deg, #ff4757, #ff6b7a);
}

.strength-fill.medium {
  background: linear-gradient(90deg, #ffa726, #ffcc02);
}

.strength-fill.strong {
  background: linear-gradient(90deg, #2ed573, #7bed9f);
}

.strength-text {
  font-weight: 600;
  min-width: 24px;
}

.strength-text.weak {
  color: #ff4757;
}

.strength-text.medium {
  color: #ffa726;
}

.strength-text.strong {
  color: #2ed573;
}

/* 账户信息样式 */
.account-info {
  max-width: 800px;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 24px;
}

.info-item {
  background: #f8f9fa;
  border-radius: 12px;
  padding: 20px;
  border: 1px solid #e9ecef;
  transition: all 0.3s ease;
}

.info-item:hover {
  background: #fff;
  border-color: #667eea;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.1);
  transform: translateY(-2px);
}

.info-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: #666;
  margin-bottom: 8px;
}

.info-label .el-icon {
  font-size: 16px;
  color: #667eea;
}

.info-value {
  font-size: 16px;
  font-weight: 600;
  color: #2c3e50;
  word-break: break-all;
}

/* 响应式设计 */
@media (max-width: 1200px) {
  .profile-content {
    max-width: 100%;
    padding: 0 16px;
  }

  .avatar-section {
    flex: 0 0 280px;
  }
}

@media (max-width: 768px) {
  .profile-container {
    padding: 16px;
  }

  .page-header {
    margin-bottom: 24px;
    padding: 20px;
  }

  .header-content {
    flex-direction: column;
    gap: 16px;
    text-align: center;
  }

  .page-title {
    font-size: 28px;
    justify-content: center;
  }

  .profile-content {
    flex-direction: column;
    gap: 20px;
  }

  .avatar-section {
    flex: none;
  }

  .avatar-card {
    padding: 24px 20px;
  }

  .form-section {
    padding: 24px 20px;
  }

  .info-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .form-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .form-actions .el-button {
    width: 100%;
    margin: 0;
  }
}

@media (max-width: 480px) {
  .page-title {
    font-size: 24px;
  }

  .section-title {
    font-size: 20px;
  }

  .username {
    font-size: 20px;
  }

  .user-avatar {
    width: 100px !important;
    height: 100px !important;
  }
}

/* 动画效果 */
.profile-container {
  animation: fadeInUp 0.8s ease-out;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(40px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.avatar-card {
  animation: slideInLeft 0.6s ease-out 0.2s both;
}

.info-section {
  animation: slideInRight 0.6s ease-out 0.4s both;
}

@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* 加载状态 */
.el-button.is-loading {
  pointer-events: none;
}

/* 滚动条样式 */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(135deg, #667eea, #764ba2);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(135deg, #5a6fd8, #6a4190);
}

/* 表单验证错误样式 */
.profile-form :deep(.el-form-item.is-error .el-input__wrapper),
.password-form :deep(.el-form-item.is-error .el-input__wrapper) {
  border-color: #f56c6c;
  box-shadow: 0 0 0 2px rgba(245, 108, 108, 0.2);
}

.profile-form :deep(.el-form-item.is-error .el-textarea__inner),
.password-form :deep(.el-form-item.is-error .el-textarea__inner) {
  border-color: #f56c6c;
  box-shadow: 0 0 0 2px rgba(245, 108, 108, 0.2);
}

/* 成功状态样式 */
.profile-form :deep(.el-form-item.is-success .el-input__wrapper),
.password-form :deep(.el-form-item.is-success .el-input__wrapper) {
  border-color: #67c23a;
  box-shadow: 0 0 0 2px rgba(103, 194, 58, 0.2);
}
</style>
